package C027;

import C017.main;

import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * ClassName: C02
 * Package: C027
 * Description:
 *
 * @Author BCXJ
 * @Create 2024/12/12 18:07
 * @Version 1.0
 * @Since 1.0
 */
public class C02 {
    static int N;
    static int[][] arr = new int[10001][2];
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        for (int i = 0; i < N; i++) {
            arr[i][0] = scanner.nextInt();
            arr[i][1] = scanner.nextInt();
        }
        System.out.println(process());

    }


    public static int process() {
        // arr 按照arr[0]排好序
        Arrays.sort(arr,0, N, (o1, o2) -> o1[0] - o2[0]);

        PriorityQueue<Integer> heap = new PriorityQueue<>();
        int res = 0;
        for (int i = 0; i < N; i++) {

            while(!heap.isEmpty() && heap.peek() <= arr[i][0]) {
                heap.poll();
            }
            heap.add(arr[i][1]);
            res = Math.max(res, heap.size());
        }
        return res;
    }
}
